﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BeniBastanYaratProject.Yonetim
{
    public partial class UrunsilDetay : System.Web.UI.Page
    {
        DBBaglantiDataContext db = new DBBaglantiDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {


            if (Page.IsPostBack)
                return;
            if (Request.QueryString["uid"] != null)
            {
                ViewState["urunid"] = int.Parse(Request.QueryString["uid"]);

                var sorgu = (from x in db.Urunlers where x.UrunID == Convert.ToInt32(ViewState["urunid"]) select x).SingleOrDefault();

                if (sorgu != null)
                {
                    lblurunadi.Text=sorgu.UrunAdi;
                    lblbeden.Text = sorgu.BedenNo.ToString();
                    lblurunaciklama.Text = sorgu.UrunAciklamasi;
                    lblurunbarkot.Text = sorgu.UrunBarkod;
                    lblurunstok.Text = sorgu.UrunStok.ToString();




                }

            }



        }

        protected void btnsil_Click(object sender, EventArgs e)
        {
            var sorgu = (from x in db.Urunlers where x.UrunID == Convert.ToInt32(ViewState["urunid"]) select x).SingleOrDefault();

            if (sorgu != null)
            {
                db.Urunlers.DeleteOnSubmit(sorgu);
                db.SubmitChanges();
                Response.Redirect("UrunSil.aspx");
            }




        }


     
    }
}